/*
 * Utility
 *
 *  Created on: 03/ott/2013
 *      Author: escion
 */

#ifndef UTILITY_
#define UTILITY_
using namespace std;
using namespace cv;

typedef struct list_nodes{
	string ipAddress;
	float bandwidth;
	int socket;
	int CPUspeed;
	int load;
	int width;
	int height;
	double time;
	int keypointsDetected;
	vector<float> keypoints;
	int descriptorsSize;
	vector<uchar> descriptors;
}list_nodes;

typedef struct broadcast_packet{
	int payloadDimension;
	int packetNumber;
	//Maximum UDP payload length (65507 - 8)
	uchar data[3000];
}broadcast_packet;

void unicast(int,int,int,int);
void broadcast(int,int,int,int,int);
void orderNodes(int,list_nodes[]);
void printErrorLog(string);
void createHeader(broadcast_packet[],int,int);
float getBandwidth(bool);
void computeLoadUnicast(int,list_nodes[],int,int);
void computeLoadBroadcast(int,list_nodes[],int);
double computeMaximumProcessingTime(int,list_nodes[]);
int check(int,list_nodes[],vector<KeyPoint>,Mat);
int deserializeSpeed(char[]);
uchar* createInfoPacket(uchar*,int,int,int);
void receiveData(int,list_nodes[]);
int compareBytes(uchar,uchar);

#endif /* UTILITY_ */
